package com.lc.command;

import org.json.JSONObject;

/**
 * Created by zhyioo on 2017/8/8.
 */

public class CommandWorker extends CommandRunner {

    public CommandWorker() {
        super();
    }

    protected ICommand _GetWorkCMD(String sModule, String sCmd) {
        ICommandDriver driver = this._moduleMap.get(sModule);
        if(driver == null) {
            return null;
        }
        ComplexCommand workCmd = new ComplexCommand(driver, sCmd);
        return workCmd;
    }

    public boolean Async(CommandDispatcher dispatcher, String sModule, String sCmd, JSONObject arg, ICommand callback) {
        ICommand workCmd = _GetWorkCMD(sModule, sCmd);
        return dispatcher.Async(workCmd, arg, callback);
    }

    public boolean Background(CommandDispatcher dispatcher, String sModule, String sCmd, JSONObject arg, ICommand callback) {
        ICommand workCmd = _GetWorkCMD(sModule, sCmd);
        return dispatcher.Background(workCmd, arg, callback);
    }
}
